<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of form
 *
 * @author yifa
 */
class Form {
        //put your code here
        
        public static function editor($content = '', $name, $type = 'ueditor', $toolbar = 'basic', $width = 800, $height = 200){
                $html = '';
                if($type == 'ueditor'){
                        if($toolbar == 'full'){
                                $toolbars = "toolbars:[
                                        ['fullscreen', 'source', '|', 'undo', 'redo', '|',
                                            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                                            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                                            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                                            'directionalityltr', 'directionalityrtl', 'indent', '|',
                                            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                                            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                                            'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe','insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
                                            'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
                                            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|',
                                            'print', 'preview', 'searchreplace', 'help']
                                    ]";
                        }else if($toolbar == 'mini'){
                                $toolbars = "toolbars:[[\"bold\",\"italic\",\"undo\",\"redo\"]]";
                        }else{
                                $toolbars = "toolbars:[
                                        ['fullscreen', 'undo', 'redo', '|',
                                            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                                            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                                            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                                            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                                            'link', 'unlink', 'anchor', '|',
                                            'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'template', '|',
                                            'horizontal', 'date', 'time', 'spechars', '|',
                                            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|',
                                            'print', 'preview', 'searchreplace', 'help']
                                    ]";
                        }
                        $html = "<script type=\"text/javascript\" src=\"".PLUGIN_PATH."ueditor/ueditor.config.js\"></script>  
                                <script type=\"text/javascript\" src=\"".PLUGIN_PATH."ueditor/ueditor.all.min.js\"></script>
                                        <textarea name=\"$name\" id=\"$name\"></textarea>
                                        <script type=\"text/javascript\"> 

                                        //var editor = new UE.ui.Editor(option);　　　//将设置初始化（之前的配置采用的是默认的，所以没有传参数）
                                        //editor.render('$name');
                                        UE.getEditor('$name', {
                                                initialFrameWidth : $width,
                                                initialFrameHeight: $height,
                                                        $toolbars,
                                                initialContent: '$content',
                                        });
                                        </script> ";
                }
                echo $html;
        }
        
}

?>
